<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>同一父容器中的sticky元素</title>
</head>

<body>
    这些stick元素位于同一个父容器内时，当滚动的一定位置时，后面的会覆盖前面的
    <div class="sticky">
        <div>君不见，高堂明镜悲白发-1</div>
        <div>君不见，高堂明镜悲白发-2</div>
        <div>君不见，高堂明镜悲白发-3</div>
        <div>君不见，高堂明镜悲白发-4</div>
        <div>君不见，高堂明镜悲白发-5</div>
        <div>君不见，高堂明镜悲白发-6</div>
        <div>君不见，高堂明镜悲白发-7</div>
        <div>君不见，高堂明镜悲白发-8</div>
        <div>君不见，高堂明镜悲白发-9</div>
    </div>

    <style>
        .sticky {
            overflow: auto;
            width: 300px;
            height: 400px;
        }

        .sticky div {
            position: sticky;
            top: 0px;
            height: 160px;
            background-color: lightpink;
            margin-bottom: 20px;
        }
    </style>

</body>

</html>